package com.egene.tw.activity.member;

import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.egene.tw.R;
import com.egene.tw.base.BaseActivity;
import com.egene.tw.model.UserCenterItem;
import com.egene.tw.utils.TitleUtil;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.Extra;
import org.androidannotations.annotations.ViewById;

@EActivity(R.layout.activity_know_detail)
public class KnowDetailActivity extends BaseActivity {
    //ToolBar Views
    @ViewById(R.id.actionBar)
    Toolbar mToolbarView;
    @ViewById(R.id.toolbar_title)
    TextView mToolBarTitle;

    @ViewById
    TextView tvRisk;
    @ViewById
    TextView tvRiskResult;
    @ViewById
    TextView tvDesc;

    @Extra
    UserCenterItem userCenterItem;


    @AfterViews
    void initViews(){
        initToolBar();
        if(userCenterItem != null){
            switch (userCenterItem.getRiskvalue().intValue()){
                case UserCenterItem.RISK_SMALL:
                    tvRisk.setBackgroundResource(R.color.risk_small);
                    break;
                case UserCenterItem.RISK_MEDIUM:
                    tvRisk.setBackgroundResource(R.color.risk_medium);
                    break;
                case UserCenterItem.RISK_HIGH:
                    tvRisk.setBackgroundResource(R.color.risk_high);
                    break;
            }
            tvRisk.setText(userCenterItem.getRiskname());
            tvRiskResult.setText(Html.fromHtml(userCenterItem.getRiskremark()));
            tvDesc.setText(Html.fromHtml(userCenterItem.getGenemeaning()));
            mToolBarTitle.setText(TitleUtil.getTitle(userCenterItem.getName()));

        }
    }


    private void initToolBar() {
        mToolBarTitle.setText(R.string.detail);
        mToolbarView.setNavigationIcon(R.drawable.ic_back);
        mToolbarView.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

}
